<?php


	if (!isset($_POST['is_submitted'])) {
    	$_POST['is_submitted'] = '';
	}
	if (!isset($_POST['email'])) {
		$_POST['email'] = '';
	}
	
	if (!isset($error_message)) {
		$error_message = '';
	}
	

	
	if ($_POST['is_submitted']) {
		
		$error_message = '';
		
 		if (!$_POST['name']) $error_message .= __ERM_NO_NAME;
		if (!$_POST['email']) $error_message .= __ERM_NO_EMAIL;
		
		else $_POST['email'] = escape($_POST['email']);
		
		if (checkEmail($_POST['email'])== 0) $error_message .= __ERM_EMAIL_NO_VALID;
		
		if (!$_POST['phone']) $error_message .= __ERM_NO_PHONE;
		
		if (!$_POST['message']) $error_message .= __ERM_NO_MESSAGE;
		
		
		
		#OK
		if (!$error_message) {

				
				
				  
				  mail( ADMINISTRATOR_EMAIL,
				   __MESSAGE_SUBJECT,
					sprintf(__MESSAGE_MESSAGE, $_POST['name'],$_POST['phone'],$_POST['fax'],$_POST['message']),
						HTML_HEADERS."From: ".DOMAIN_NAME." <".$_POST['email'].">");
				 
			 $_SESSION['message'] = __MESSAGE_SENT;	
			 $_POST['name'] = '';
			 $_POST['phone'] = '';
			 $_POST['message'] = '';
			 $_POST['email'] = '';
			 $_POST['fax'] = '';
		}
	}
	
	
	
	
	$sql = "SELECT
			d.title,
			d.description,
			d.meta_key,
			d.meta_description
		FROM
			pages AS c,
			page_description AS d
		WHERE
		
			c.page_id = d.page_id
			
			AND
			
			d.lang_id = '".$_SESSION["lang_id"]."'
			
			AND
			
			c.published
			
			AND c.sef_url = 'contacts' 
		  ";
$result = query($sql);
$row = mysql_fetch_object($result);
head(sth($row->title),$row->meta_description,$row->meta_key);
	
?>
 	
	
 
	<div id="loginform">
			
			<h3><?=stripslashes($row->title)?></h3>
            
            
            <?php if ($error_message) { ?>
            <div class="message red">
                <?=$error_message?>
            </div>
            <?php } ?>
            
            <?php if ($_SESSION['message']) { ?>
            <div class="message green">
                <?=$_SESSION['message']?>
            </div>
            <?php } ?>
            
            <?=stripslashes($row->description)?>
            <form action="<?=HTML_BASE.$_SESSION["lang"].'/contacts/'?>" method="post" enctype="multipart/form-data">
            
            
            
            
            <input type="hidden" name="is_submitted" value="1" />
			
            <table style="margin:auto;" width="70%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>
                <label for="name" class="required"><?=__FULL_NAME?></label><br>
            <input class="inputbox" name="name" type="text" value="<?=$_POST['fullname']?>" >
            </td>
               <td>
              		<label for="email" class="required">E-mail</label><br>
            <input class="inputbox" name="email" type="text" value="<?=$_POST['email']?>" ><br>
              
              </td>
              </tr>
              
              <tr>
                <td><label for="phone" class="required"><?=__PHONE?></label><br>
            <input class="inputbox" name="phone" type="text" value="<?=$_POST['phone']?>" ><br>
            </td>
               <td><label for="fax" ><?=__FAX?></label><br>
            <input class="inputbox" name="fax" type="text" value="<?=$_POST['fax']?>" ><br>
            </td>
              </tr>
              
              
               <tr>
                <td >
                <label for="message" ><?=__MESSAGE?></label><br>
                <textarea rows="6" name="message" class="inputbox"><?=$_POST['message']?></textarea>
               
            </td>
            <td >
			<br>
			<input  type="submit" name="submit" id="submit" class="button" value="<?=__SEND?>">
                
                </td>
              </tr>
              
            </table>
			
			</form>
            
	</div>
    

<?php
foot();
?>